package www.dashu.com.domain;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.Formula;
import www.dashu.com.domain.base.BaseVo;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;

@Data
@Entity
@Table(name="oms_cart_item")
public class OmsCartItem extends BaseVo implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("")
    @Id
    private Long id;

    @ApiModelProperty("商品ID")
    @Column(name = "product_id")
    private Long productId;

    @ApiModelProperty("商品规格值")
    @Column(name = "product_attribute_value")
    private String productAttributeValue;

    @ApiModelProperty("用户ID")
    @Column(name = "u_id")
    private Long uId;

    @ApiModelProperty("购买数量")
    @Column(name = "quantity")
    private Integer quantity;

    @ApiModelProperty("添加到购物车的价格")
    @Column(name = "price")
    private Double price;

    @ApiModelProperty("商品主图")
    @Column(name = "product_pic")
    private String productPic;

    @ApiModelProperty("商品名称")
    @Column(name = "product_name")
    private String productName;

    @ApiModelProperty("商品副标题（卖点）")
    @Column(name = "product_sub_title")
    private String productSubTitle;

    @ApiModelProperty("商品sku条码")
    @Column(name = "product_sku_code")
    private String productSkuCode;

    @ApiModelProperty("商品分类")
    @Column(name = "product_category_id")
    private Long productCategoryId;

    @ApiModelProperty("商品品牌")
    @Column(name = "product_brand")
    private String productBrand;

    @ApiModelProperty("删除状态：0->未删除；1->已删除")
    @Column(name = "delete_status")
    private Integer deleteStatus;

    @ApiModelProperty("所属商户")
    @Formula("(select s.name from sys_company s where s.id = company )")
    private String companyName;

    @Column(name = "company")
    private Long company;

    @ApiModelProperty("所属应用")
    @Formula("(select s.name from sys_app s where s.id = app_id )")
    private String appName;

    @Column(name = "app_id")
    private Long appId;

    @ApiModelProperty("创建时间")
    @Column(name = "create_time")
    private Date createTime;

    @ApiModelProperty("更新时间")
    @Column(name = "update_time")
    private Date updateTime;


    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", productId=").append(productId);
        sb.append(", productAttributeValue=").append(productAttributeValue);
        sb.append(", uId=").append(uId);
        sb.append(", quantity=").append(quantity);
        sb.append(", price=").append(price);
        sb.append(", productPic=").append(productPic);
        sb.append(", productName=").append(productName);
        sb.append(", productSubTitle=").append(productSubTitle);
        sb.append(", productSkuCode=").append(productSkuCode);
        sb.append(", productCategoryId=").append(productCategoryId);
        sb.append(", productBrand=").append(productBrand);
        sb.append(", deleteStatus=").append(deleteStatus);
        sb.append(", company=").append(company);
        sb.append(", appId=").append(appId);
        sb.append(", createTime=").append(createTime);
        sb.append(", updateTime=").append(updateTime);
        sb.append("]");
        return sb.toString();
    }

}